package tools;

import java.util.regex.Pattern;

/**
 * Used in the administration panel to verify if an email is valid or not.
 * @author Guillaume Pocas & Jean-François Augé
 * @see http://www.developpez.net/forums/d34321/java/general-java/apis/java-util/pattern-regex-v-rifier-email-valide/
 */
public class EMailVerificator {

	private static String pattern = "^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)+$";
	
	/**
	 * Return true the email is valid.
	 * @param email
	 * @return boolean
	 */
	public static boolean match(String email) {
		return Pattern.matches(pattern, email);
	}
	
	
	// tests
	public static void main(String[] args) {
		System.out.println(EMailVerificator.match("helloworld@email.com"));
		System.out.println(EMailVerificator.match("failmail@.com"));
	}

}
